package de.hhn.mim.psb;

import org.junit.Test;

public class TestPCA {
	/*
	 *  Vorgabe Datenmatrix
	 * | 3 5 7 9 |
	 * | 2 3 4 5 |
	 * | 2 2 2 2 |
	 * Ergebnis sollte sein:
	 * EVals = [0, 0, >0]
	 * v1 = [0,0,1], 
	 * v2 = [-0,45,0.89,0] 
	 * v3 = [-0.89,-0.45,0]
	 * Ergebnis in PCA.calcEigenvalueDecompostion():
	 * EVals = [0, 0, 6.25]
	 * v1 = [0.447, -0.894], 
	 * v2 = [0,0,1], 
	 * v3 = [0,894, 0.447, 0]
	*/
	@Test
	public void pca(){
		Vect3D [] points = new Vect3D [4];
		points[0] = new Vect3D(3,2,2);
		points[1] = new Vect3D(5,3,2);
		points[2] = new Vect3D(7,4,2);
		points[3] = new Vect3D(9,5,2);

		System.out.println("beisp2_PCAScriptMaierHein\n");
		PCA3D pca = new PCA3D(points);
		double [] EVals = pca.getEigenValues();
		double [][] eigenVectors   = pca.getEigenVectors();
		double [][] sortEigenVects = pca.getSortEigenVects();
		double []   sortEigenVals  = pca.getSortEigenVals();

		Matrix3D eigenMat     = new Matrix3D(eigenVectors);
		Matrix3D sortEigenMat = new Matrix3D(sortEigenVects);

		Vect3D myEigenVals = new Vect3D(EVals[0], EVals[1], EVals[2]);
		myEigenVals.print(    "eigenValues    ");
		eigenMat.print("eigenVectors ");
		System.out.println("\n\n\n");
	}

}
